#coding:utf-8


__all__ = [
#'monitor',
'photo',
#'wirelessdownload',
#'versionquery',
]


"""
# py2exe打包不能以这种方式包含文件
for module in __all__:
    exec "import %s"%module
"""

#import monitor
#import versionquery
import photo
#import wirelessdownload


hunters = {}
interpreters = {}
operations = []

def initializeMarket():
    for module_name in __all__:
        module = eval(module_name)
        
        # init hunters
        hunters.update(module.hunters)
        
        #init interpreters
        interpreters.update(module.interpreters)
        
        # init operations
        operations.append(module.operations)
        

# 初始化业务映射
initializeMarket()

import datamethod as dm

def hireHunter(busstype):
    if isinstance(busstype, list):
        busstype = dm.data2str(busstype)
    return hunters.get(busstype, None)
            
def findProtocol(busstype):
    if not isinstance(busstype, list):
        busstype = dm.str2data(busstype)
    for operation in operations:
        for p in operation[1]:
            if busstype == p.getType():
                return p
            
def findInterpreter(busstype):
    if isinstance(busstype, list):
        busstype = dm.data2str(busstype)
    return  interpreters.get(busstype, None)
        
        

